package com.zzoranor.FragmentTest;

import com.zzoranor.DialogTest.R;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class DialogTestActivity extends FragmentActivity {
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button b = (Button) findViewById(R.id.button1);
        b.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				addFragment();
				
			}
		});
    }
    
    public void addFragment()
    {
    	FragmentManager fm = getSupportFragmentManager();
    	FragmentTransaction ft = fm.beginTransaction();
    	ViewFragmentTest vf = new ViewFragmentTest();
    	ViewGroup vg = (ViewGroup) findViewById(R.id.container);
    	vg.removeView(vg.findViewById(R.id.button1));
    	ft.add(R.id.container, vf);
    	ft.commit();
    }
   
    
}